package com.ygsoft.activiti.listener;

import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * 全局监听事件
 *
 * @author zhx
 * @create 2017-11-20 9:10
 **/
@Service("GlobalTaskListener")
public class GlobalTaskListener implements TaskListener {
    protected Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void notify(DelegateTask delegateTask) {
        String eventName = delegateTask.getEventName();

        System.out.println("触发了监听器GlobalTaskListener pid=" + delegateTask.getProcessInstanceId() + " taskId=" + delegateTask.getId() + "事件名称:" + delegateTask.getEventName());

        if ("create".endsWith(eventName)) {
            System.out.println("create=========");
        }else if ("assignment".endsWith(eventName)) {
            System.out.println("assignment========");
        }else if ("complete".endsWith(eventName)) {
            System.out.println("complete===========");
        }else if ("delete".endsWith(eventName)) {
            System.out.println("delete=============");
        }
    }
}
